package com.changpay.zywy.adapter

import android.content.Context
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.changpay.zywy.R
import com.changpay.zywy.bean.AllocLogBean

/**
 * Created by chenxz on 2018/4/22.
 */
class AllowCommitAdapter(private val context: Context?, datas: MutableList<AllocLogBean>) :
    BaseQuickAdapter<AllocLogBean, BaseViewHolder>(R.layout.item_allow, datas) {
    override fun convert(helper: BaseViewHolder?, item: AllocLogBean?) {
        item ?: return
        helper ?: return

        helper.setText(R.id.tv_allot_people, item.apply_member_name)
            .setText(R.id.tv_be_alloc, item.member_name)
            .setText(R.id.tv_phone, item.member_mobile)
            .setText(R.id.tv_time, item.created_time_date)
        if (item.position == 1)
        {
            if (item.state == "0") {
                helper.setText(R.id.tv_state, "待审核")
                helper.setBackgroundRes(R.id.tv_state, R.mipmap.icon_commit_wait)
            } else  if (item.state == "1"){
                helper.setText(R.id.tv_state, "已通过")
                helper.setBackgroundRes(R.id.tv_state, R.mipmap.icon_commit_all)
            }else  if (item.state == "2"){
                helper.setText(R.id.tv_state, "已拒绝")
                helper.setBackgroundRes(R.id.tv_state, R.mipmap.icon_commit_ref)
            }
        }else
        {
            if (item.state == "0") {
                helper.setText(R.id.tv_state, "待审核")
                helper.setBackgroundRes(R.id.tv_state, R.mipmap.icon_commit_wait)
            } else {
                helper.setText(R.id.tv_state, "已拒绝")
                helper.setBackgroundRes(R.id.tv_state, R.mipmap.icon_commit_ref)
            }
        }

    }

}
